Python turtle库的应用实例 | 您所在的位置:网站首页 › 用python turtle画图源代码 › Python turtle库的应用实例 |
时间已来到二月,情人节就要到了。在今年的特殊环境下,想必很多人都要和自己的心上人异地相隔过节了(比如久久不被允许返校的学生党),那么如何给自己的男/女朋友送上一份惊喜呢?如果你的对象恰巧会那么一点python,不妨试试利用python的第三方库turtle,略表自己心意吧。 先放一张成品图: 写上文字,画大白: #初始化画布 t.setup(width=800, height=600) time.sleep(2) #上部文字 t.hideturtle() t.color("#FF6A6A") t.penup() t.goto(-300,220) words1 = '当' words2 = ['送','给','小','可','爱'] for i in range(4): t.write(words1, font=("华文彩云", 3*i+14, "bold")) t.forward(20+3*i) time.sleep(0.15) t.forward(8) t.write("!", font=("华文彩云", 23, "bold")) t.forward(20) time.sleep(0.5) for word in words2: t.write(word, font=("华文彩云", 26, "bold")) t.forward(35) time.sleep(0.4) t.write(":", font=("华文彩云", 23, "bold")) t.forward(35) #大白 #头 t.goto(-100,150) t.right(90) t.color("black") t.pensize(1) t.pendown() size = 0.6 a = 0.8*size for i in range(120): if 0 |
CopyRight 2018-2019 实验室设备网 版权所有 |